home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0039 / spr_des / source / sprite.asm < prev   
Assembly Source File  |  1997-04-16  |  31KB  |  624 lines

  1. * Robert Warnestam, 3 May 1990
  2. * Source code to GFA basic, DEMOSPR (or your own programs)
  3. * Source File: SPRITE.ASM
  4. * Compile to File: SPRITE.MC
  5.  
  6.  
  7. * -----------------------------------------------------------------------------
  8. * How to use from GFA BASIC:
  9. *
  10. * mc$=STRING$(2000,0)         ;resreve space for this assembler program
  11. * mc%=VARPTR(mc$)             ;address to start of program
  12. * BLOAD "SPRITE.MC",mc%       ;load program
  13. * mc%=mc%+28                  ;skip file header
  14. * mcstart%=mc%+30             ;first 30 bytes is data
  15. *
  16. * POKE mc%,MODE               ;select MODE
  17. * -----------------------------------------------------------------------------
  18. * MODE=1 =>                   'Set Palette'
  19. *                             Set palette to a specified image bank.
  20. * POKE mc%+1,bank%            bank number, 0-15
  21. * -----------------------------------------------------------------------------
  22. * MODE=2 =>                   'Screen Changed'
  23. *                             If you had made changes on the screen,
  24. *                              you have to call this routine.
  25. * -----------------------------------------------------------------------------
  26. * MODE=3 =>                   'All Sprite Off'
  27. *                             Turn all sprites off,remove from screen
  28. * -----------------------------------------------------------------------------
  29. * MODE=4 =>                   'Sprite Off'
  30. *                             Turn off a single sprite, you will see the effect
  31. *                              after next 'Update' or 'Screen Changed'
  32. * POKE mc%+2,sprite           sprite number, 0-15
  33. * -----------------------------------------------------------------------------
  34. * MODE=5 =>                   'Set Sprite'
  35. *                             Set position and image to a sprite, you will see
  36. *                              the effect after next 'Update' or
  37. *                              'Screen Changed'
  38. * POKE mc%+2,sprite           sprite number, 0-15
  39. * DPOKE mc%+4,x               x position, 0-350
  40. * DPOKE mc%+6,y               y position, 0-230
  41. * POKE mc%+1,bank             in which image bank are the image, 0-15
  42. * POKE mc%+3,image            image, 0-15
  43. * -----------------------------------------------------------------------------
  44. * MODE=6 =>                   'Update'
  45. *                             Update sprite position & image
  46. *                             This routine first, draws the new sprite on the
  47. *                              log screen, then it swaps the log & phys
  48. *                              screens and makes a VSYNC.
  49. *                             At last it removes the old sprites (now in
  50. *                              the log screen)
  51. * -----------------------------------------------------------------------------
  52. * MODE=7 =>                   'Begin It'
  53. *                             Set screen ptr's.
  54. * LPOKE mc%+8,logscreen       This is a second screen, used in screen flipping
  55. *                              it have to be at 256 boundrary and 32000bytes
  56. * LPOKE mc%+12,physscreen     This is the original screen, used in screen
  57. *                              flipping. Get the address with XBIOS(2)
  58. * LPOKE mc%+16,spritescreen   This is a screen used when the program erases
  59. *                              the sprite, it is a copy of the original
  60. *                              screen with no sprites. It does't have to be
  61. *                              at 256 boundary. 32000 bytes long
  62. * -----------------------------------------------------------------------------
  63. * MODE=8 =>                   'End It'
  64. *                             You have to enter this routine before your
  65. *                              program finish. It set the screen pointers
  66. *                              to the original screen (Phys)
  67. * -----------------------------------------------------------------------------
  68. * MODE=9 =>                   'Set Bank'
  69. *                             When you have loaded a '*.SPR' file (sprite file
  70. *                              created with 'SPR_DES.PRG' then you enter
  71. *                              this rountine with the address of the loaded
  72. *                              file, so the program nows where it get it's
  73. *                              graphic from.
  74. * POKE mc%+1,bank             bank number to be set, 0-15
  75. * LPOKE mc%+20,bank_ptr       ptr to image bank
  76. * -----------------------------------------------------------------------------
  77. * At last....
  78. * CALL mcstart%
  79. * -----------------------------------------------------------------------------
  80.  
  81. *
  82. * EQU's for variables from user to program
  83. MODE           EQU  0
  84. BANK_NR        EQU  1
  85. SPRITE_NR      EQU  2
  86. IMAGE_NR       EQU  3
  87. X              EQU  4
  88. Y              EQU  6
  89. LOG_SCR        EQU  8
  90. PHYS_SCR       EQU  12
  91. SPR_SCR        EQU  16
  92. BANK_PTR       EQU  20
  93.  
  94. * EQU's for sprite drawing/undrawing
  95. SPR_X          EQU  0
  96. SPR_Y          EQU  2
  97. SPR_IMG_PTR    EQU  4
  98. SPR_ON_FLAG    EQU  8
  99. SPR_OFFSET_OLD EQU  10
  100. SPR_WIDTH_OLD  EQU  12
  101. SPR_HEIGHT_OLD EQU  14
  102. SPR_OFFSET_NEW EQU  16
  103. SPR_WIDTH_NEW  EQU  18
  104. SPR_HEIGHT_NEW EQU  20
  105.  
  106. var            DS.B 30                            ;program starts after this
  107.  
  108. *
  109. * start of code...
  110. *
  111.  
  112. * Check what user want to do...
  113.                     lea       var(pc),a6
  114.                     clr       d0
  115.                     move.b    MODE(a6),d0
  116.                     cmp       #1,d0
  117.                     beq       Set_Palette
  118.                     cmp       #2,d0
  119.                     beq       Screen_Changed
  120.                     cmp       #3,d0
  121.                     beq       All_Sprite_Off
  122.                     cmp       #4,d0
  123.                     beq       Sprite_Off
  124.                     cmp       #5,d0
  125.                     beq       Set_Sprite
  126.                     cmp       #6,d0
  127.                     beq       Update
  128.                     cmp       #7,d0
  129.                     beq       Begin_It
  130.                     cmp       #8,d0
  131.                     beq       End_It
  132.                     cmp       #9,d0
  133.                     beq       Set_Bank
  134.                     rts
  135.  
  136. *******************************************************************************
  137. * Mode 1: Set Palette
  138. *         Set palette, get color from a image bank
  139. *         In: bank_nr
  140. *******************************************************************************
  141. Set_Palette         clr       d0
  142.                     move.b    BANK_NR(a6),d0
  143.                     lsl       #2,d0               ;each 1 longword
  144.                     lea       bank_ptrs(pc),a0    ;ptr list (16 ptr's)
  145.                     lea       0(a0,d0.w),a0       ;ptr in list
  146.                     move.l    (a0),d0             ;get ptr
  147.                     move.l    d0,-(sp)            ;first 32 byte is palette
  148.                     move      #6,-(sp)            ;SETPALETTE
  149.                     trap      #14                 ;XBIOS
  150.                     addq.l    #6,sp
  151.                     rts
  152. *******************************************************************************
  153. * Mode 2: Screen Changed
  154. *         Screen (LOG) has changed...
  155. *              1- Copy LOG screen to SPR screen
  156. *              2- Call 'Update'
  157. *              3- Copy SPR screen to LOG screen
  158. *******************************************************************************
  159. Screen_Changed      move.l    log_screen(pc),a0
  160.                     move.l    sprite_screen(pc),a1
  161.                     move      #999,d0
  162. scr_change_loop1    move.l    (a0)+,(a1)+         ;copy 8 longwords
  163.                     move.l    (a0)+,(a1)+         ;1000 times
  164.                     move.l    (a0)+,(a1)+         ;=>32000 bytes
  165.                     move.l    (a0)+,(a1)+
  166.                     move.l    (a0)+,(a1)+
  167.                     move.l    (a0)+,(a1)+
  168.                     move.l    (a0)+,(a1)+
  169.                     move.l    (a0)+,(a1)+
  170.                     dbra      d0,scr_change_loop1
  171.                     bsr       Update
  172.                     move.l    log_screen(pc),a1
  173.                     move.l    sprite_screen(pc),a0
  174.                     move      #99,d0
  175.                     move      #999,d0
  176. scr_change_loop2    move.l    (a0)+,(a1)+         ;copy 8 longwords
  177.                     move.l    (a0)+,(a1)+         ;1000 times
  178.                     move.l    (a0)+,(a1)+         ;=>32000 bytes
  179.                     move.l    (a0)+,(a1)+
  180.                     move.l    (a0)+,(a1)+
  181.                     move.l    (a0)+,(a1)+
  182.                     move.l    (a0)+,(a1)+
  183.                     move.l    (a0)+,(a1)+
  184.                     dbra      d0,scr_change_loop2
  185.                     rts
  186. *******************************************************************************
  187. * Mode 3: All Sprites Off
  188. *         Remove all sprites
  189. *******************************************************************************
  190. All_Sprite_Off      lea       sprite_data(pc),a0
  191.                     move      #15,d0
  192. all_off_loop        sf        SPR_ON_FLAG(a0)
  193.                     add.l     #22,a0              ;next sprite
  194.                     dbra      d0,all_off_loop
  195.                     bsr       Update              ;remove from screen
  196.                     rts
  197. *******************************************************************************
  198. * Mode 4: Sprite Off
  199. *         Remove one sprite (just in memory, remove from screen with 'Update')
  200. *         In: sprite_nr
  201. *******************************************************************************
  202. Sprite_Off          lea       sprite_data(pc),a0
  203.                     clr       d0
  204.                     move.b    SPRITE_NR(a6),d0
  205.                     mulu      #22,d0              ;each sprite data,22 bytes
  206.                     lea       0(a0,d0.w),a0       ;ptr to sprite data
  207.                     sf        SPR_ON_FLAG(a0)     ;remove
  208.                     rts
  209. *******************************************************************************
  210. * Mode 5: Set Sprite
  211. *         Derfine a sprite, position and image (draw in next 'Update')
  212. *         In: x, y, sprite_nr, bank_nr, image_nr
  213. *******************************************************************************
  214. Set_Sprite          lea       sprite_data(pc),a0
  215.                     clr       d0
  216.                     move.b    SPRITE_NR(a6),d0
  217.                     mulu      #22,d0              ;each sprite data 22 bytes
  218.                     lea       0(a0,d0.w),a0       ;ptr to sprite data
  219.                     lea       bank_ptrs(pc),a1
  220.                     clr       d0
  221.                     move.b    BANK_NR(a6),d0
  222.                     lsl       #2,d0               ;each 1 longword
  223.                     lea       0(a1,d0.w),a1       ;ptr to ptr
  224.                     move.l    (a1),a1             ;ptr to start of a bank
  225.                     add.l     #36,a1              ;skip palette (+4bytes)
  226.                     clr       d0
  227.                     move.b    IMAGE_NR(a6),d0
  228.                     move      #9,d1
  229.                     lsl       d1,d0               ;each image 512 bytes
  230.                     lea       0(a1,d0.w),a1       ;ptr to image in a bank
  231.                     st        SPR_ON_FLAG(a0)     ;sprite on
  232.                     move.l    a1,SPR_IMG_PTR(a0)  ;save image ptr
  233.                     move      X(a6),SPR_X(a0)
  234.                     move      Y(a6),SPR_Y(a0)
  235.                     rts
  236. *******************************************************************************
  237. * Mode 6: Update
  238. *         Draw new sprites, swap screens, undraw old sprites
  239. *******************************************************************************
  240. Update              lea       sprite_data(pc),a5
  241.                     move      #15,d0              ;16 sprites
  242. update_loop1        tst.b     SPR_ON_FLAG(a5)     ;draw this sprite?
  243.                     beq       update_next1        ;no
  244.                     bsr       draw_sprite
  245. update_next1        move      SPR_OFFSET_OLD(a5),d1    ;swap _OLD & _NEW
  246.                     move      SPR_OFFSET_NEW(a5),d2    ;vars set in
  247.                     move      d2,SPR_OFFSET_OLD(a5)    ;'draw_sprite'
  248.                     move      d1,SPR_OFFSET_NEW(a5)    ;and used in
  249.                     move      SPR_WIDTH_OLD(a5),d1     ;'undraw_sprite'
  250.                     move      SPR_WIDTH_NEW(a5),d2
  251.                     move      d2,SPR_WIDTH_OLD(a5)
  252.                     move      d1,SPR_WIDTH_NEW(a5)
  253.                     move      SPR_HEIGHT_OLD(a5),d1
  254.                     move      SPR_HEIGHT_NEW(a5),d2
  255.                     move      d2,SPR_HEIGHT_OLD(a5)
  256.                     move      d1,SPR_HEIGHT_NEW(a5)
  257.                     add.l     #22,a5              ;next sprite
  258.                     dbra      d0,update_loop1
  259.                     lea       phys_screen(pc),a0
  260.                     lea       log_screen(pc),a1
  261.                     move.l    (a0),d1             ;swap phys & log screens
  262.                     move.l    (a1),d2
  263.                     move.l    d2,(a0)
  264.                     move.l    d1,(a1)
  265.                     move      #-1,-(sp)           ;res.
  266.                     move.l    d2,-(sp)            ;phys
  267.                     move.l    d1,-(sp)            ;log
  268.                     move      #5,-(sp)            ;SETSCREEN
  269.                     trap      #14                 ;XBIOS
  270.                     add.l     #12,sp              ;tidy
  271.                     move      #37,-(sp)           ;VSYNC
  272.                     trap      #14                 ;XBIOS
  273.                     add.l     #2,sp               ;tidy
  274.                     lea       sprite_data(pc),a5
  275.                     move      #15,d0                   ;16 sprites
  276. update_loop2        cmp       #-1,SPR_OFFSET_OLD(a5)   ;undraw sprite?
  277.                     beq       update_next2             ;no
  278.                     bsr       undraw_sprite
  279.                     move      #-1,SPR_OFFSET_OLD(a5)   ;ok with undrawing
  280. update_next2        add.l     #22,a5              ;next sprite
  281.                     dbra      d0,update_loop2
  282.                     rts
  283. *******************************************************************************
  284. * Mode 7: Begin It
  285. *         Init screens
  286. *         In: log_scr, phys_scr, spr_scr
  287. *******************************************************************************
  288. Begin_It
  289.                     move.l    LOG_SCR(a6),a0
  290.                     move.l    PHYS_SCR(a6),a1
  291.                     move.l    SPR_SCR(a6),a2
  292.                     lea       log_screen(pc),a3
  293.                     move.l    a0,(a3)
  294.                     lea       phys_screen(pc),a3
  295.                     move.l    a1,(a3)
  296.                     lea       old_phys_screen(pc),a3
  297.                     move.l    a1,(a3)
  298.                     lea       sprite_screen(pc),a3
  299.                     move.l    a2,(a3)
  300.                     move      #7999,d0            ;8000 long words
  301. begin_loop1         clr.l     (a0)+               ;clear screens...
  302.                     clr.l     (a1)+
  303.                     clr.l     (a2)+
  304.                     dbra      d0,begin_loop1
  305.                     lea       sprite_data(pc),a0
  306.                     move      #15,d0
  307. begin_loop2         sf        SPR_ON_FLAG(a0)          ;sprite off
  308.                     move      #-1,SPR_OFFSET_OLD(a0)   ;don't undraw
  309.                     move      #-1,SPR_OFFSET_NEW(a0)   ;don't undraw
  310.                     add.l     #22,a0                   ;next sprite
  311.                     dbra      d0,begin_loop2
  312.                     bsr       Update                   ;set screens
  313.                     rts
  314. *******************************************************************************
  315. * Mode 8: End It
  316. *         Set original screens
  317. *******************************************************************************
  318. End_It              move.l    old_phys_screen(pc),d0
  319.                     move      #-1,-(sp)                ;res.
  320.                     move.l    d0,-(sp)                 ;phys
  321.                     move.l    d0,-(sp)                 ;log
  322.                     move      #5,-(sp)                 ;SETSCREEN
  323.                     trap      #14                      ;XBIOS
  324.                     add.l     #12,sp                   ;tidy
  325.                     rts
  326. *******************************************************************************
  327. * Mode 9: Set Bank
  328. *         Set address to an image bank (created with SPR_DES)
  329. *         In: bank_nr, bank_ptr
  330. *******************************************************************************
  331. Set_Bank            clr       d0
  332.                     move.b    BANK_NR(a6),d0
  333.                     lsl       #2,d0               ;each 1 longword
  334.                     lea       bank_ptrs(pc),a0
  335.                     lea       0(a0,d0.w),a0       ;ptr to ptr in list
  336.                     move.l    BANK_PTR(a6),(a0)   ;set address
  337.                     rts
  338. *******************************************************************************
  339. * Routines used from this program
  340. * Erase sprite
  341. * In: A5.L ptr to sprite data area
  342. undraw_sprite       movem.l   d0-d1/a0-a2,-(sp)
  343.                     move.l    SPR_OFFSET_OLD(a5),d0    ;offset on screen
  344.                     move.l    log_screen(pc),a2        ;undraw screen
  345.                     move.l    sprite_screen(pc),a1     ;get data from this scr
  346.                     add.l     d0,a2                    ;add offset
  347.                     add.l     d0,a1
  348.                     move      SPR_HEIGHT_OLD(a5),d1    ;visible sprite height-1
  349.                     move      SPR_WIDTH_OLD(a5),d0     ;x-words saved
  350.                     cmp       #1,d0               ;16 pixel saved?
  351.                     beq       un16
  352.                     cmp       #2,d0               ;32 pixel saved?
  353.                     beq       un32                ;else 48 pixel saved!
  354. un48                move.l    (a1)+,(a2)+         ;copy 48pixel*4planes=24bytes
  355.                     move.l    (a1)+,(a2)+
  356.                     move.l    (a1)+,(a2)+
  357.                     move.l    (a1)+,(a2)+
  358.                     move.l    (a1)+,(a2)+
  359.                     move.l    (a1)+,(a2)+
  360.                     add.l     #136,a2             ;next line
  361.                     add.l     #136,a1
  362.                     dbf       d1,un48
  363.                     movem.l   (sp)+,d0-d1/a0-a2
  364.                     rts
  365. un32                move.l    (a1)+,(a2)+         ;copy 32pixel*4planes=16bytes
  366.                     move.l    (a1)+,(a2)+
  367.                     move.l    (a1)+,(a2)+
  368.                     move.l    (a1)+,(a2)+
  369.                     add.l     #144,a2             ;next line
  370.                     add.l     #144,a1
  371.                     dbf       d1,un32
  372.                     movem.l   (sp)+,d0-d1/a0-a2
  373.                     rts
  374. un16                move.l    (a1)+,(a2)+         ;copy 16pixel*4planes=8bytes
  375.                     move.l    (a1)+,(a2)+
  376.                     add.l     #152,a2             ;next line
  377.                     add.l     #152,a1
  378.                     dbf       d1,un16
  379.                     movem.l   (sp)+,d0-d1/a0-a2
  380.                     rts
  381. *******************************************************************************
  382. * Draw sprite
  383. * In: A5.L ptr to sprite data area
  384. draw_sprite         movem.l   d0-d7/a0-a1,-(sp)
  385.                     move.l    SPR_IMG_PTR(a5),a1  ;ptr to image
  386.                     move      SPR_X(a5),d0        ;x
  387.                     move      SPR_Y(a5),d1        ;y
  388.                     cmp       #350,d0             ;inside x boundaries?
  389.                     bhi       doexit
  390.                     cmp       #230,d1
  391.                     bhi       doexit
  392.                     move.l    #0,a0               ;offset on screen(inc.later)
  393.                     cmp       #30,d1              ;sprite at top?
  394.                     bhi       donotop
  395.                     move      d1,d2               ;#lines-1=y0
  396.                     eor       #31,d1              ;start=31-y0
  397.                     bra       doyok
  398. donotop             cmp       #199,d1             ;sprite in middle?
  399.                     bhi       donomiddle
  400.                     move      d1,d7               ;screen=y0-31
  401.                     sub       #31,d7
  402.                     mulu      #160,d7
  403.                     add.w     d7,a0               ;inc. screen offset
  404.                     clr       d1                  ;start=0
  405.                     move      #31,d2              ;#lines-1=31
  406.                     bra       doyok
  407. donomiddle          move      d1,d7               ;screen=y0-31
  408.                     sub       #31,d7
  409.                     mulu      #160,d7
  410.                     add.w     d7,a0               ;inc. screen offset
  411.                     move      d1,d2               ;#lines-1=31-(y0-199)
  412.                     sub       #199,d2
  413.                     eor       #31,d2
  414.                     clr       d1                  ;start=0
  415. doyok               move      d2,SPR_HEIGHT_OLD(a5)    ;save height-1
  416.                     lsl       #4,d1               ;adjust image ptr
  417.                     lea       0(a1,d1.w),a1       ; to current sprite height
  418.                     cmp       #14,d0              ;sprite on left side?
  419.                     bhi       nol1
  420. *Sprite on the left side (0-50%)
  421.                     move      #1,SPR_WIDTH_OLD(a5)     ;save x-words (16 pixel)
  422.                     move.l    a0,SPR_OFFSET_OLD(a5)    ;save screen offset
  423.                     add.l     log_screen(pc),a0        ;screen+offset
  424.                     and       #15,d0                   ;x MOD 15=rotations
  425.                     addq      #1,d0               ;at least one pixel visible
  426.                     addq.l    #8,a1                  ;skip left side of sprite
  427. dloop1              bsr       pixleft
  428.                     add.l     #160,a0                  ;next line
  429.                     add.l     #8,a1                    ;skip left side
  430.                     dbf       d2,dloop1
  431.                     bra       doexit
  432. nol1                cmp       #30,d0                   ;sprite on left side?
  433.                     bhi       nol2
  434. *Sprite on the left side (50-100%)
  435.                     move      #2,SPR_WIDTH_OLD(a5)     ;save x-words (32 pixel)
  436.                     move.l    a0,SPR_OFFSET_OLD(a5)    ;save screen offset
  437.                     add.l     log_screen(pc),a0        ;screen+offset
  438.                     sub       #15,d0                   ;begin x=0
  439.                     and       #15,d0                   ;rotations
  440. dloop2              bsr       pixleft
  441.                     bsr       pix16
  442.                     add.l     #160,a0                  ;next line
  443.                     dbf       d2,dloop2
  444.                     bra       doexit
  445. nol2                cmp       #319,d0                  ;sprite in the middle
  446.                     bhi       nocenter
  447. *Sprite in the middle
  448.                     move      #3,SPR_WIDTH_OLD(a5)     ;save x-words (48 pixel)
  449.                     sub       #31,d0                   ;begin x=0
  450.                     move      d0,d3
  451.                     and       #15,d0                   ;rotations
  452.                     lsr       #4,d3                    ;x-byte=4*(x DIV 16)
  453.                     lsl       #3,d3
  454.                     lea       0(a0,d3.w),a0            ;inc. screen offset
  455.                     move.l    a0,SPR_OFFSET_OLD(a5)    ;save screen offset
  456.                     add.l     log_screen(pc),a0        ;screen+offset
  457. dloop3              bsr       pix16
  458.                     add.l     #8,a0                    ;next 16 pixel
  459.                     bsr       pix16
  460.                     add.l     #152,a0                  ;next line
  461.                     dbf       d2,dloop3
  462.                     bra       doexit
  463. nocenter            cmp       #335,d0                  ;sprite on right side?
  464.                     bhi       doright2
  465. *Sprite on the right side (50-100%)
  466.                     move      #2,SPR_WIDTH_OLD(a5)     ;save x-words (32 pixel)
  467.                     add.l     #144,a0                  ;inc. screen offset
  468.                     move.l    a0,SPR_OFFSET_OLD(a5)    ;save screen offset
  469.                     add.l     log_screen(pc),a0        ;screen+offset
  470.                     sub       #320,d0                  ;begin x=0
  471.                     and       #15,d0                   ;rotations
  472.                     addq      #1,d0               ;at least one pixel visible
  473. dloop4              bsr       pix16
  474.                     add.l     #8,a0                    ;next 16 pixel
  475.                     bsr       pixright
  476.                     add.l     #152,a0                  ;next line
  477.                     dbf       d2,dloop4
  478.                     bra       doexit
  479. *Sprite on the right side (0-50%)
  480. doright2            move      #1,SPR_WIDTH_OLD(a5)     ;save x-words (16 pixel)
  481.                     add.l     #152,a0             ;inc. screen offset
  482.                     move.l    a0,SPR_OFFSET_OLD(a5)    ;save screen offset
  483.                     add.l     log_screen(pc),a0        ;screen+offset
  484.                     sub       #336,d0             ;begin x=0
  485.                     and       #15,d0              ;rotations
  486.                     addq      #1,d0               ;at least one pixel visib
  487. dloop5              bsr       pixright
  488.                     add.l     #8,a1               ;skip right side on sprite
  489.                     add.l     #160,a0             ;next line
  490.                     dbf       d2,dloop5
  491. doexit              movem.l   (sp)+,d0-d7/a0-a1
  492.                     rts
  493. *
  494. pix16               move      (a1)+,d4            ;get sprite data
  495.                     move      (a1)+,d5            ;4 planes a 16 pixel
  496.                     move      (a1)+,d6
  497.                     move      (a1)+,d7
  498.                     swap      d4                  ;sprite in high words
  499.                     swap      d5
  500.                     swap      d6
  501.                     swap      d7
  502.                     clr       d4                  ;clear low word
  503.                     clr       d5
  504.                     clr       d6
  505.                     clr       d7
  506.                     lsr.l     d0,d4               ;rotate
  507.                     lsr.l     d0,d5
  508.                     lsr.l     d0,d6
  509.                     lsr.l     d0,d7
  510.                     move.l    d4,d3               ;make mask
  511.                     or.l      d5,d3               ;color 0 = transparent
  512.                     or.l      d6,d3
  513.                     or.l      d7,d3
  514.                     and.l     d3,d4               ;mask sprite data
  515.                     and.l     d3,d5
  516.                     and.l     d3,d6
  517.                     and.l     d3,d7
  518.                     not.l     d3                  ;mask screen
  519.                     and       d3,$8(a0)
  520.                     and       d3,$a(a0)
  521.                     and       d3,$c(a0)
  522.                     and       d3,$e(a0)
  523.                     swap      d3
  524.                     and       d3,$0(a0)
  525.                     and       d3,$2(a0)
  526.                     and       d3,$4(a0)
  527.                     and       d3,$6(a0)
  528.                     swap      d3
  529.                     add       d4,$8(a0)           ;add screen with sprite
  530.                     add       d5,$a(a0)
  531.                     add       d6,$c(a0)
  532.                     add       d7,$e(a0)
  533.                     swap      d4
  534.                     swap      d5
  535.                     swap      d6
  536.                     swap      d7
  537.                     add       d4,$0(a0)
  538.                     add       d5,$2(a0)
  539.                     add       d6,$4(a0)
  540.                     add       d7,$6(a0)
  541.                     rts
  542. pixleft             move      (a1)+,d4            ;get sprite data
  543.                     move      (a1)+,d5
  544.                     move      (a1)+,d6
  545.                     move      (a1)+,d7
  546.                     swap      d4                  ;sprite in high word
  547.                     swap      d5
  548.                     swap      d6
  549.                     swap      d7
  550.                     clr       d4                  ;clear low word
  551.                     clr       d5
  552.                     clr       d6
  553.                     clr       d7
  554.                     lsr.l     d0,d4               ;rotate
  555.                     lsr.l     d0,d5
  556.                     lsr.l     d0,d6
  557.                     lsr.l     d0,d7
  558.                     move      d4,d3               ;make mask
  559.                     or        d5,d3
  560.                     or        d6,d3
  561.                     or        d7,d3
  562.                     and       d3,d4               ;mask sprite data(bit0-15)
  563.                     and       d3,d5
  564.                     and       d3,d6
  565.                     and       d3,d7
  566.                     not       d3                  ;mask screen
  567.                     and       d3,$0(a0)
  568.                     and       d3,$2(a0)
  569.                     and       d3,$4(a0)
  570.                     and       d3,$6(a0)
  571.                     add       d4,$0(a0)           ;add screen with sprite
  572.                     add       d5,$2(a0)
  573.                     add       d6,$4(a0)
  574.                     add       d7,$6(a0)
  575.                     rts
  576. pixright            move      (a1)+,d4            ;get sprite data
  577.                     move      (a1)+,d5
  578.                     move      (a1)+,d6
  579.                     move      (a1)+,d7
  580.                     swap      d4                  ;sprite in high word
  581.                     swap      d5
  582.                     swap      d6
  583.                     swap      d7
  584.                     lsr.l     d0,d4               ;rotate
  585.                     lsr.l     d0,d5
  586.                     lsr.l     d0,d6
  587.                     lsr.l     d0,d7
  588.                     swap      d4                  ;sprite in low word
  589.                     swap      d5
  590.                     swap      d6
  591.                     swap      d7
  592.                     move      d4,d3               ;make mask
  593.                     or        d5,d3
  594.                     or        d6,d3
  595.                     or        d7,d3
  596.                     and       d3,d4               ;mask sprite data
  597.                     and       d3,d5
  598.                     and       d3,d6
  599.                     and       d3,d7
  600.                     not       d3                  ;mask screen
  601.                     and       d3,$0(a0)
  602.                     and       d3,$2(a0)
  603.                     and       d3,$4(a0)
  604.                     and       d3,$6(a0)
  605.                     add       d4,$0(a0)           ;add screen with sprite
  606.                     add       d5,$2(a0)
  607.                     add       d6,$4(a0)
  608.                     add       d7,$6(a0)
  609.                     rts
  610. * Pointers to 16 image banks, 16 longword
  611. bank_ptrs           ds.l      16
  612.  
  613. * Sprite data, 22 bytes each
  614. sprite_data         ds.b      16*22
  615.  
  616. * Screen pointers
  617. log_screen          ds.l      1
  618. phys_screen         ds.l      1
  619. sprite_screen       ds.l      1
  620. old_phys_screen     ds.l      1
  621.  
  622.  
  623.                     END
  624.